<?php
require_once(dirname(__FILE__)."/../src/product_mod_init_get_productid.php");
require_once(dirname(__FILE__)."/../src/product_mod_insert_product_info.php");
require_once(dirname(__FILE__)."/../src/product_mod_get_product_info.php");

try{
	if($_SERVER['REQUEST_METHOD'] == "POST")
	{
		switch ($_POST['act'])
		{
			case 'init_get_productid':
				echo init_get_productid($_POST['partyid']);
				break;

			case 'insert_product_info':
				echo insert_product_info( $_POST['productid'], $_POST['des'] );
			    break;

			default:
				throw new Exception('POST_Serviceurl_Not_Found'); 
				break;
		}


	}
	else if($_SERVER['REQUEST_METHOD'] == "GET")
	{
		switch ($_GET['act'])
		{				
			case 'get_product_info':
				echo get_product_info( $_GET['productid'] );
				break;

			default:
				throw new Exception('GET_Serviceurl_Not_Found');
				break;
		}
	}
	else
	{
		throw new Exception('Err_Not_GET_POST_Serviceurl');
	}
}

catch(Exception $e){
  
  date_default_timezone_set('PRC');
  error_log( date("Y-m-d   H:i:s")."   "."line: ".$e->getLine()." in file: ".$e->getFile()." throw exception.\r\n", 3, "./php_exception_catch_log.log");
  error_log( $e->getTraceAsString()."\r\n\r\n", 3, "./php_exception_catch_log.log");

  echo 'serviceurl_unexpected_error';
 }//捕获异常


?>